﻿using System;
using Monkey.Framework.Configuration;

namespace Monkey.Framework.Logging
{
    public class LoggingFactory
    {
        private static ILogger _logger;

        private static readonly object _lock = new object();
        
        /// <summary>
        /// Gets the logger.
        /// </summary>
        /// <returns>ILogger instance</returns>
        public static ILogger GetLogger()
        {
            lock (_lock)
            {
                if (_logger == null)
                {
                    switch (ApplicationSettings.LoggerName)
                    {
                        case "Log4Net":
                            _logger = new Log4NetAdapter();
                            break;

                        default:
                            throw new Exception("Logging type is not supported!");
                    }
                }
            }

            return _logger;
        }
    }
}
